﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WEALTH.Manager.Customer
{
    public partial class FcTestManage : BasePage
    {
        ExcuteDao dao = new ExcuteDao();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetInfo();
            }
        }

        private void GetInfo()
        {
            DataTable dt1 = dao.GET_CsSetting();

            if (dt1 != null && dt1.Rows.Count > 0)
            {
                txtFcbs.Text = dt1.Rows[0]["csBsValue"].ToString();
                txtFcwj.Text = dt1.Rows[0]["csWjValue"].ToString();
                txtFccz.Text = dt1.Rows[0]["csCzValue"].ToString();
                txtFcjq.Text = dt1.Rows[0]["csJqValue"].ToString();
                txtFcjj.Text = dt1.Rows[0]["csJjValue"].ToString();
            }
        }

        protected void btnInsert_Click(object sender, EventArgs e)
        {
            int id = 0;
            try
            {
                //验证页面数据
                if (!CheckData())
                {
                    return;
                }

                if (dao.Update_CsSetting(
                   txtFcbs.Text,
                   txtFcwj.Text,
                   txtFccz.Text,
                   txtFcjq.Text,
                   txtFcjj.Text
                    ) == -1)
                {
                    ReturnList("FcTestManage.aspx", "修改信息成功！");

                }
                else
                {
                    ShowMsg("修改信息失败，请确认！", 1);
                }
            }
            catch (Exception ex)
            {
                ShowMsg(ex.Message.ToString(), 1);
            }
        }

        /// <summary>
        /// 验证页面内容
        /// </summary>
        /// <returns></returns>
        private bool CheckData()
        {
            if (string.IsNullOrEmpty(txtFcbs.Text.TrimEnd()))
            {
                ShowMsg("请输入保守型分值！", 1);
                txtFcbs.Focus();
                return false;
            }
            if (string.IsNullOrEmpty(txtFcwj.Text.TrimEnd()))
            {
                ShowMsg("请输入稳健型分值！", 1);
                txtFcwj.Focus();
                return false;
            }
            if (string.IsNullOrEmpty(txtFccz.Text.TrimEnd()))
            {
                ShowMsg("请输入成长型分值！", 1);
                txtFccz.Focus();
                return false;
            }
            if (string.IsNullOrEmpty(txtFcjq.Text.TrimEnd()))
            {
                ShowMsg("请输入进取型分值！", 1);
                txtFcjq.Focus();
                return false;
            }
            if (string.IsNullOrEmpty(txtFcjj.Text.TrimEnd()))
            {
                ShowMsg("请输入激进型分值！", 1);
                txtFcjj.Focus();
                return false;
            }

            return true;
        }
    }
}